home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 29 / CDT29.iso / e-Mail / WorldClient Pro 2.2.3 / wcsetup.exe / WEBHELP.ZIP / sitemap / SiteMapParser.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-10-21  |  3.3 KB  |  151 lines

  1. package sitemap;
  2.  
  3. import hhapplet.URLFileHandler;
  4. import java.applet.Applet;
  5. import java.awt.Label;
  6. import java.net.URL;
  7. import java.util.Properties;
  8.  
  9. public class SiteMapParser extends Thread {
  10.    protected MyBufferedInputStream m_isInputStream;
  11.    protected Properties m_properties;
  12.    protected SiteMapParserOutput m_smpoOutput;
  13.    protected String m_strFileName;
  14.    protected URL m_urlDocBase;
  15.    protected Applet m_applet;
  16.  
  17.    public void parse() {
  18.       int var1 = 0;
  19.  
  20.       try {
  21.          this.m_isInputStream = new MyBufferedInputStream(URLFileHandler.makeURL(this.m_urlDocBase, this.m_strFileName, (String)null).openStream());
  22.       } catch (Exception var5) {
  23.          this.m_applet.add("Center", new Label("Can't open URL or file " + ((Throwable)var5).getMessage()));
  24.          return;
  25.       }
  26.  
  27.       this.m_smpoOutput.start();
  28.  
  29.       try {
  30.          for(Tag var2 = Tag.readTag(this.m_isInputStream); !(var2 instanceof HtmlTag); var2 = Tag.readTag(this.m_isInputStream)) {
  31.          }
  32.  
  33.          Tag var7 = Tag.readTag(this.m_isInputStream);
  34.  
  35.          while(!(var7 instanceof HtmlEndTag)) {
  36.             if (var7 instanceof ObjectTag) {
  37.                if (((ObjectTag)var7).getType().equalsIgnoreCase("text/site properties")) {
  38.                   for(Tag var8 = Tag.readTag(this.m_isInputStream); !(var8 instanceof ObjectEndTag); var8 = Tag.readTag(this.m_isInputStream)) {
  39.                      if (var8 instanceof ParamTag) {
  40.                         try {
  41.                            this.m_smpoOutput.param(((ParamTag)var8).getName(), ((ParamTag)var8).getValue());
  42.                         } catch (NullPointerException var4) {
  43.                         }
  44.                      }
  45.                   }
  46.                } else {
  47.                   while(!(var7 instanceof ObjectEndTag)) {
  48.                      var7 = Tag.readTag(this.m_isInputStream);
  49.                   }
  50.                }
  51.             } else if (var7 instanceof UlTag) {
  52.                this.parseULTag();
  53.             }
  54.  
  55.             var7 = Tag.readTag(this.m_isInputStream);
  56.             ++var1;
  57.             if (var1 % 10 == 0) {
  58.                System.gc();
  59.                Runtime.getRuntime().gc();
  60.             }
  61.          }
  62.       } catch (TagInvalidException var6) {
  63.          ((Throwable)var6).printStackTrace();
  64.       }
  65.  
  66.       try {
  67.          this.m_isInputStream.close();
  68.       } catch (Exception var3) {
  69.       }
  70.  
  71.       this.m_smpoOutput.end();
  72.    }
  73.  
  74.    public SiteMapParserOutput getOutput() {
  75.       return this.m_smpoOutput;
  76.    }
  77.  
  78.    public Thread parseInSeparateThread(String var1, URL var2, Applet var3) {
  79.       this.m_strFileName = var1;
  80.       this.m_urlDocBase = var2;
  81.       this.m_applet = var3;
  82.       ((Thread)this).setPriority(4);
  83.       ((Thread)this).start();
  84.       return this;
  85.    }
  86.  
  87.    public SiteMapParser(SiteMapParserOutput var1) {
  88.       this.m_smpoOutput = var1;
  89.       this.m_properties = new Properties();
  90.    }
  91.  
  92.    public void parseInCurrentThread(String var1, URL var2, Applet var3) {
  93.       this.m_strFileName = var1;
  94.       this.m_urlDocBase = var2;
  95.       this.m_applet = var3;
  96.       this.parse();
  97.    }
  98.  
  99.    protected void parseULTag() throws TagInvalidException {
  100.       for(Tag var1 = Tag.readTag(this.m_isInputStream); !(var1 instanceof UlEndTag); var1 = Tag.readTag(this.m_isInputStream)) {
  101.          if (var1 instanceof LiTag) {
  102.             this.parseLiTag();
  103.          } else if (var1 instanceof UlTag) {
  104.             this.m_smpoOutput.indent(1);
  105.             this.parseULTag();
  106.             this.m_smpoOutput.indent(-1);
  107.          }
  108.       }
  109.  
  110.    }
  111.  
  112.    public void closeFiles() {
  113.       try {
  114.          this.m_isInputStream.close();
  115.       } catch (Exception var1) {
  116.       }
  117.    }
  118.  
  119.    protected void parseLiTag() throws TagInvalidException {
  120.       Tag var1 = Tag.readTag(this.m_isInputStream);
  121.       if (!(var1 instanceof ObjectTag)) {
  122.          if (var1 instanceof UlTag) {
  123.             this.m_smpoOutput.indent(1);
  124.             this.parseULTag();
  125.             this.m_smpoOutput.indent(-1);
  126.          }
  127.  
  128.       } else {
  129.          this.m_smpoOutput.object_start();
  130.          if (((ObjectTag)var1).getType().equalsIgnoreCase("text/sitemap")) {
  131.             for(Tag var2 = Tag.readTag(this.m_isInputStream); !(var2 instanceof ObjectEndTag); var2 = Tag.readTag(this.m_isInputStream)) {
  132.                if (var2 instanceof ParamTag) {
  133.                   this.m_smpoOutput.param(((ParamTag)var2).getName(), ((ParamTag)var2).getValue());
  134.                }
  135.             }
  136.  
  137.             this.m_smpoOutput.object_end();
  138.          } else {
  139.             while(!(var1 instanceof ObjectEndTag)) {
  140.                var1 = Tag.readTag(this.m_isInputStream);
  141.             }
  142.  
  143.          }
  144.       }
  145.    }
  146.  
  147.    public void run() {
  148.       this.parse();
  149.    }
  150. }
  151.